package com.example.ymm.modules1.service.impl.sys;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.ymm.base.BaseServiceImpl;
import com.example.ymm.model.TableList;
import com.example.ymm.model.YmPageDto;
import com.example.ymm.modules1.entity.my.sys.SysApprovalSettingNode;
import com.example.ymm.modules1.mapper.my.sys.SysApprovalSettingNodeMapper;
import com.example.ymm.modules1.query.sys.SysApprovalSettingNodeQueryCriteria;
import com.example.ymm.modules1.service.sys.SysApprovalSettingNodeService;
import com.example.ymm.util.QueryHelpPlus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@DS("slave2")
@Slf4j
public class SysApprovalSettingNodeServiceImpl extends BaseServiceImpl<SysApprovalSettingNodeMapper, SysApprovalSettingNode> implements SysApprovalSettingNodeService {

    @Override
    public TableList<SysApprovalSettingNode> list(SysApprovalSettingNodeQueryCriteria criteria, YmPageDto pageDto) {
        IPage<SysApprovalSettingNode> page = new Page<SysApprovalSettingNode>(pageDto.getPage(),pageDto.getPageSize());
        QueryWrapper predicate = QueryHelpPlus.getPredicate(SysApprovalSettingNode.class, criteria);
        predicate.orderByAsc("sort");
        baseMapper.selectPage(page, predicate);
        TableList<SysApprovalSettingNode> tableList=new TableList(page);
        return tableList;
    }

    public List<SysApprovalSettingNode> queryAll(SysApprovalSettingNodeQueryCriteria criteria) {
        QueryWrapper predicate = QueryHelpPlus.getPredicate(SysApprovalSettingNode.class, criteria);
        predicate.orderByAsc("sort");
        List<SysApprovalSettingNode> result =baseMapper.selectList(predicate);
        return result;
    }
}
